//#include <iostream.h>
#include <stdio.h>
#include <process.h>
#include <string.h>
#include <conio.h>
//#define NULL 0

void printdata(struct tel_man *);
struct tel_man *inputdata(void);
struct tel_man *finddata(struct tel_man *);
struct tel_man *head;

struct tel_man
{
	char name[20];
	char age;
    char address[50];
    struct tel_man *next;
};

int main(void)
{
	char tmp;
	struct tel_man *p1,*p2;
	clrscr();
	printf("Please input communication data.\n");
    p1=inputdata();
	head=p1;p2=p1;
	while(p1->name)
	{
        p1=inputdata();
        p2->next=p1;
        p2=p1;
    }
    p2->next=NULL;

    printf("Do you want to find data ?");
    scanf("%c",&tmp);
    if(tmp!='Y' || tmp!='y') exit(0);
	else
    {
        printf("Please enter the data .");
        p1=inputdata();
		p2=finddata(p1);
		if(p2!=NULL)    printdata(p2);
		else    printf("Can't find the data .");
    }
	return 0;
}

struct tel_man *inputdata(void)
{
	struct tel_man body;
	printf("Name:");    scanf("%s",body.name);
	printf("Ege:");  	  scanf("%d",body.age);
	printf("Address:");  scanf("%s",body.address);
	return &body;
}

struct tel_man *finddata(struct tel_man *pstr)
{
    struct tel_man *pp;
    pp=head;
	do
    {
        if(strcmp(pp->name,pstr->name)==0)
        {
            if(pp->age==pstr->age)
            {
                if(strcmp(pp->address,pstr->address)==0)
                return pp;
            }
        }
    }while(pp!=NULL);
    getch();
	return 0;
}

void printdata(struct tel_man *pstr)
{
    printf("%s",pstr->name);
    printf("%d",pstr->age);
    printf("%s",pstr->address);
	//return 0;
}









